home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / stdio / vsprintf.c < prev   
C/C++ Source or Header  |  1997-09-09  |  803b  |  55 lines

  1.  
  2. /*
  3.  *  VSPRINTF.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <stdarg.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <lib/misc.h>
  14.  
  15. #ifndef HYPER
  16. #define HYPER(x) x
  17. #endif
  18.  
  19. static unsigned int
  20. _swrite(buf, n1, n2, sst)
  21. char *buf;
  22. size_t n1;
  23. size_t n2;
  24. const char **sst;
  25. {
  26.     size_t n;
  27.  
  28.     if (n1 == 1)
  29.     n = n2;
  30.     else if (n2 == 1)
  31.     n = n1;
  32.     else
  33.     n = n1 * n2;
  34.  
  35.     movmem(buf, *sst, n);
  36.     *sst += n;
  37.     return(n2);
  38. }
  39.  
  40. int
  41. HYPER(vsprintf)(buf, ctl, va)
  42. char *buf;
  43. const char *ctl;
  44. va_list va;
  45. {
  46.     char *ptr = buf;
  47.     int error;
  48.  
  49.     error = _pfmt(ctl, va, _swrite, &ptr);
  50.     va_end(va);
  51.     *ptr = 0;
  52.     return(error);      /*  count/error */
  53. }
  54.  
  55.